home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gigarom 1
/
Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso
/
FILES
/
DEV
/
A-B
/
Alpha.5.05.cpt
/
shell.tcl
< prev
next >
Wrap
Text File
|
1992-09-06
|
1KB
|
64 lines
proc initShell {} {
insertText "Welcome to Alpha's Tcl shell."
shellPrompt [lindex [winNames] 0]
}
# Output the prompt. We want the window name because some of the commands
# we evaluate (such as 'edit') open a new window, and we want the insertion
# to be done in the shell window.
proc shellPrompt {winName} {
regexp "(\[^:\]*):$" [pwd] crDum crDir
insertText -w $winName "\r" $crDir "> "
}
# Called at all carriage returns.
proc carriageReturn {} {
global mode
set indentString ""
deleteText [getPos] [selEnd]
if {[getVar indentOnCR]} {
set pos [getPos]
set text [getText [lineStart $pos] $pos]
for {set i 0; set len [string length $text]} {$i <= $len} {incr i} {
set c [string index $text $i]
if {($c != "\t") && ($c != "\ ")} {
set indentString [string range $text 0 [expr $i-1]]
break
}
}
}
insertText "\r" $indentString
}
proc tclCarriageReturn {} {
global mode
uplevel #0 {
set oldFor [getVar forward]
set oldReg [getVar regExpr]
set oldMatch [getVar matchWords]
set fileName [lindex [winNames] 0]
setVar forward 0
setVar regExpr 0
setVar matchWords 0
goto [maxPos]
set crText [getText [expr "[lindex [search ">" [maxPos]] 0]+2"] [maxPos]]
catch $crText crRes
if {[string length $crRes]} {
insertText -w $fileName "\r" $crRes
}
shellPrompt $fileName
setVar forward $oldFor
setVar regExpr $oldReg
setVar matchWords $oldMatch
}
}
bind '\r' carriageReturn
bind '\r' tclCarriageReturn "Csh"
# tclCarriageReturn